package my.jwds.offerII069;

public class PeakIndexInMountainArray {


    public static void main(String[] args) {
        PeakIndexInMountainArray obj = new PeakIndexInMountainArray();
        System.out.println(obj.peakIndexInMountainArray(new int[]{1,2,3,4,5,6,1,2}));
    }

    public int peakIndexInMountainArray(int[] arr) {
        return peakIndexInMountainArray(arr,0,arr.length-1);
    }

    public int peakIndexInMountainArray(int[] arr,int left,int right) {
        if (right == left)return left;
        int newRight = (left+right)/2;
        int newLeft = newRight+1;
        return arr[newRight]>arr[newLeft]?peakIndexInMountainArray(arr,left,newRight):peakIndexInMountainArray(arr,newLeft,right);
    }

}
